// auto();
events.observeNotification();
events.on("notification", function(n){
    log(n.getTitle() +"\n" + n.getText() + " \n" + n.getPackageName());

    if ("com.tencent.mm" == n.getPackageName() && "____quick" == n.getTitle()) {
        try {
            var context = "" + n.getText();
            if (context.endsWith('cmd')) {
                log("接受内容:" + context);
                h(context);
            }
        } catch(e) {
            console.error($debug.getStackTrace(e));
        }
    }
});


function h(context) {
    var cmd = context;
    if (cmd.indexOf('____quick') >= 0) {
        cmd = cmd.substring(cmd.indexOf('____quick') + 11);
    }
    switch(cmd) {
        case "截图cmd":
            app.sendBroadcast({
                action:"com.hz.intent.jietu",
                extras: {},
            });
            break;
        case "打卡cmd":
            app.sendBroadcast({
                action:"com.hz.intent.dk",
                extras: {},
            });
            break;
        case "邮件cmd":
            app.sendBroadcast({
                action:"com.hz.intent.sendmsg",
                extras: {
                    'fileName' : "wxdk.jpg"
                },
            });
            break;
    }
}
